<?php
namespace app\index\Validate;


use think\Validate;

class PayValidate extends Validate
{
    protected $rule = [
        'pay_img'=>'fileExt:jpg,png,jpeg|fileSize:2048000',
        'amount'=>'require|checkAmount',
        'coin_id'=>'require',
    ];

    protected $message = [
        'pay_img.fileExt'=>'充值截图必须是jpg,png,jpeg',
        'pay_img.fileSize'=>'图片不能超过2M',
        'amount.require'=>'充值金额必填',
        'amount.checkAmount'=>'充值金额必须是数字',
        'coin_id.require'=>'充值币种必须选择',
    ];
    public function checkAmount($value)
    {
        $value = floatval($value);
        if (!is_numeric($value)) {
            return false;
        }
        if ($value<0) {
            return false;
        }
        return true;
    }
}